Conversation
simon04
left a comment
There was a problem hiding this comment.
Thanks for your work. I appreciate the modernisation. For this core functionality, we should take extra care to maintain compatibility and not introduce any bugs. Please see my comments.
| onError = (type, error, options) -> | ||
| options.error?.call options.context, type, error, options |
There was a problem hiding this comment.
Here are some usages for the error handler and progress callback:
devdocs/assets/javascripts/app/db.coffee
Lines 253 to 257 in 676f4f6
devdocs/assets/javascripts/app/update_checker.coffee
Lines 14 to 17 in 14049da
devdocs/assets/javascripts/models/doc.coffee
Lines 67 to 70 in 14049da
devdocs/assets/javascripts/models/doc.coffee
Lines 114 to 119 in 14049da
| abort = (xhr) -> | ||
| clearTimeout(xhr.timer) | ||
| xhr.onreadystatechange = null | ||
| xhr.abort() | ||
| return |
There was a problem hiding this comment.
Here's one usage of abort:
devdocs/assets/javascripts/views/content/entry_page.coffee
Lines 112 to 114 in 93a42cc
| if options.dataType == 'json' | ||
| response.json() | ||
| else | ||
| response.text() |
There was a problem hiding this comment.
I think response.ok and response.status (200 <= xhr.status < 300) need to be checked.
|
hey @simon04 we were reviewing your comments and the code, and we have some concerns if this move from xhr to fetch is actually beneficial or not. I can describe a bit of what we found:
Also, we noticed one thing that seems to be a bug in the current code, this error callback is expecting thexhr as the second argument, but that's actually passed as the third argument here
We want to raise these concerns before continuing with this change, we are not sure if it's really worth it (the current code works just fine and some of the code around it was designed for how xhr works) |
@arielj, @toppa and I are submitting this PR for this issue: #1193
We had a few differences between XHR and Fetch, so we couldn't match functionality 100%.
But we think it's fine from what we saw on the code.
onProgresscallback or equivalentWe couldn't find usages of the
xhrargument on callback methods. We weren't sure about the arguments.